
<div class="form-group">
    <label for="idCode" class=" col-sm-2-label control-label" >业务编号</label>
    <div class="col-sm-10-input">
        <input type="text" class="form-control " name="adminBusiness.code" id="idCode" value="${adminBusiness?.code}" readonly placeholder="">
    </div>
    <label for="idName" class="col-sm-2-label control-label" style="">业务名称</label>
    <div class="col-sm-10-input">
        <input type="text" class="form-control" name="adminBusiness.name" value="${adminBusiness?.name}" id="idName" placeholder="">
    </div>
    <label for="idBusinessType" class="col-sm-2-label control-label" style="">业务类型</label>
    <div class="col-sm-10-input">
        <select class="form-control" name="adminBusiness.businessType" id="idBusinessType" placeholder="">
            <option value="" #{if adminBusiness?.businessType == null} selected="true"#{/if}>---请选择---</option>
            <option value="COMM" #{if adminBusiness?.businessType == models.admin.enums.BusinessType.COMM } selected="true"#{/if}>普通</option>
            <option value="REPORT" #{if adminBusiness?.businessType == models.admin.enums.BusinessType.REPORT } selected="true"#{/if}>报表</option>
        </select>
    </div>
</div>
<div class="form-group">
    <label for="idUrl" class="col-sm-2-label control-label" >链接地址</label>
    <div class=" col-sm-10-row ">
        <input type="text" class="form-control" name="adminBusiness.url" id="idUrl" value="${adminBusiness?.url}" onchange="changeUrl(this.value)" required="required" placeholder="">
    </div>
</div>
<div class="form-group">
    <label for="idController" class="col-sm-2-label control-label" >Controller</label>
    <div class=" col-sm-10-row ">
        <input type="text" class="form-control" required name="adminBusiness.controller" id="idController" value="${adminBusiness?.controller}"  placeholder="">
    </div>
</div>
<div class="form-group">
    <label for="idEntity" class="col-sm-2-label control-label" >main entity</label>
    <div class=" col-sm-10-input ">
        <input type="text" class="form-control " name="adminBusiness.mainEntity" id="idEntity" value="${adminBusiness?.mainEntity}" placeholder="">
    </div>
    <label for="idCodeDateAvailable" class=" col-sm-2-label control-label" >流水号带日期</label>
    <div class="col-sm-10-input">
        <select class="form-control" name="adminBusiness.codeDateAvailable" id="idCodeDateAvailable" placeholder="">
            <option value="" #{if adminBusiness?.codeDateAvailable == null} selected="true"#{/if}>---请选择---</option>
            <option value="AVAILABLE" #{if adminBusiness?.codeDateAvailable == models.constants.AvailableStatus.AVAILABLE } selected="true"#{/if}>启用</option>
            <option value="FREEZE" #{if adminBusiness?.codeDateAvailable == models.constants.AvailableStatus.FREEZE } selected="true"#{/if}>禁用</option>
        </select>
    *{<input type="text" class="form-control " name="adminBusiness.codeDateAvailable" id="idCodeDateAvailable" value="${adminBusiness.codeDateAvailable}" placeholder="">}*
    </div>
    <label for="idPrefix" class="col-sm-2-label control-label" >流水号前缀</label>
    <div class=" col-sm-10-input ">
        <input type="text" class="form-control " name="adminBusiness.prefix" id="idPrefix" value="${adminBusiness?.prefix}" placeholder="">
    </div>

</div>
<div class="form-group">

    <label for="idCodeDate" class="col-sm-2-label control-label" style="">流水号日期</label>
    <div class="col-sm-10-input">
        <input type="text" class="form-control" name="adminBusiness.codeDate" value="${adminBusiness?.codeDate}" id="idCodeDate" placeholder="">
    </div>
    <label for="idCodeNum" class="col-sm-2-label control-label" style="">最大流水号</label>
    <div class="col-sm-10-input">
        <input type="text" class="form-control" name="adminBusiness.codeNum" value="${adminBusiness?.codeNum}" id="idCodeNum" placeholder="">
    </div>
    <label for="idShowOrder" class="col-sm-2-label control-label" >排序号</label>
    <div class=" col-sm-10-input ">
        <input type="text" class="form-control " name="adminBusiness.showOrder" id="idShowOrder" value="${adminBusiness?.showOrder}" placeholder="">
    </div>
</div>
<div id="toolbar">
    <a href="#" type="button" class="btn btn-info"  onclick="addSystemOperate()">添加系统操作</a>
        <a href="javascript:;" onclick="addOrEdit()" class="btn btn-info">添加自定义操作</a>

</div>
<div class="table-responsive" >
    <table id="operateList" class=" table table-bordered table-striped">
        <thead>
        <tr>
            <th class="no-sorting">
                <input name="checkAll" type="checkbox" class="cbr">
            </th>
            <th>操作名称</th>
            <th>过滤关键字</th>
            <th>操作类型</th>
            <th>操作</th>
        </tr>
        </thead>

        <tbody class="middle-align">
       #{list operateList , as: 'operate'}
       <tr>
           <td><input type="checkbox" name="subBox" class="cbr"> <input name="id" value="${operate.id}" hidden="true"></td>
           <td><input class="td_input " name="name" value="${operate.name}"></td>
           <td><input class="td_input" name="filterKey" value="${operate.filterKey}"></td>
           <td> <select class="td_input" name="operateType" required>
                    <option value="" #{if operate?.operateType == null } selected="true"#{/if} >---请选择---</option>
                    <option value="CUSTOM" #{if operate?.operateType == models.admin.enums.OperateType.CUSTOM } selected="true"#{/if} >自定义</option>
                    <option value="SYSTEM" #{if operate?.operateType == models.admin.enums.OperateType.SYSTEM } selected="true"#{/if} >系统默认</option>
                </select>
           </td>
           <td>
               <a href="#" id="idBtnDel" onclick="addOrEdit(${operate.id})" class="btn btn- btn-info btn-icon icon-left">编辑</a>
               <a href="#" id="idBtnDel" onclick="deletedComfim(${operate?.id});" class="btn btn-danger btn-sm btn-icon icon-left">删除</a>
           </td>
       </tr>
       #{/list}

        </tbody>
    </table>
</div>

<script type="text/javascript" src="/public/lib/layer/js/layer.js"></script>
<script type="text/javascript">

    function addSystemOperate() {
        var businessId = $('#idBusinessId').val();
        if(businessId == null || businessId == '' ){
            layer.msg('请先保存业务,再添加操作!');
            return ;
        }
        layer.open({
            title:"添加系统操作",
            type: 2,
            area: ['600px', '500px'],
            fixed: true,
            maxmin: false,
            content: '/power/admin/AdminOperateCtrl/adminOperateList'
        });
    }

    function callBack(name , filterKey) {
        addOrEdit(-1 ,name , filterKey)
    }
    function addOrEdit(id , name , filterKey){

        var businessId = $('#idBusinessId').val();
        if(businessId == null || businessId == '' || businessId <= 0 ){
            layer.msg('请先保存业务,再添加操作!');
            return ;
        }

        var url = '/power/admin/AdminBusinessCtrl/businessOperate';

        if(id != null && id != "")
            url += "/" + id;
        else
            url += "/-1";

        url += "/${pageNumber}/${adminBusiness.id}";
        if(name != null && name != '' && filterKey != null && filterKey != ''){
            var operate = name+","+filterKey+","

            url += "?adminOperate=" + operate;
        }
        layer.open({
            title:"添加自定义操作",
            type: 2,
            area: ['600px', '500px'],
            fixed: true,
            maxmin: false,
            content: url
        });
    }


    function tipAndCloseAll(msg){
        layer.closeAll();
        layer.msg(msg);
        setTimeout("location.reload()", 1000);
    }

    //点击确认删除 之后执行的方法
    function sureDeleted() {
        //获取删除的id
        var id = $('#deleteId').val();
        document.location.href='/power/admin/AdminBusinessCtrl/deletedBusinessOperate/'+id+'/${pageNumber}';
    }

    //注册url值变化事件
    function changeUrl(newValue) {
        var splitUrl = newValue.split('/');
        var controller = '';
        for (var i = 0; i < splitUrl.length - 1; i++){
            if (splitUrl[i].length > 0){
                var str = splitUrl[i];
                controller += '/' + str;
                if(i==splitUrl.length-2){
                    $('#idEntity').val( str.substring(0,str.length - 4));
                }
            }
        }
        $('#idController').val(controller);
    }

</script>
